﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using pcsse.App_Code.DAL;

namespace pcsse.App_Code.entity
{
    public class person_info
    {
        private static DAL.personTableAdapters.T_PERSONINFOTableAdapter sPta = new DAL.personTableAdapters.T_PERSONINFOTableAdapter();
        public string GetDataFromColumn(int ID, string columnname)
        {
            try
            {
                DAL.person.T_PERSONINFODataTable sPdt = sPta.GetDataByID(ID);
                if (sPdt.Rows.Count != 1)
                {
                    return null;
                }
                else
                {
                    return sPdt.Rows[0][columnname].ToString();
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
        //从ID得到学号/工号
        public string GetNumberByID(int ID)
        {
            return GetDataFromColumn(ID, "NUMBER");
        }
        public string GetNameByID(int ID)
        {
            return GetDataFromColumn(ID, "NAME");
        }
        public int GetPriorityByID(int ID)
        {
            string re = GetDataFromColumn(ID, "PRIORITY_ID");
            if (re == null)
            {
                return 0;
            }
            return Convert.ToInt32(re);
        }
        public string GetBranchNameByID(int ID)
        {
            return GetDataFromColumn(ID, "FULLNAME");
        }
        public int GetBranchIDByID(int ID)
        {
            string re = GetDataFromColumn(ID, "BRANCH_ID");
            if (re == null)
            {
                return 0;
            }
            return Convert.ToInt32(re);
        }
    }
}
